package com.zj.restApi;

import com.zj.web.bean.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  定义一个Feign客户端接口，用于调用product服务
 *  访问product服务的api接口  由openFeign生成代理对象
 *  查询商品信息
 */

@FeignClient(name = "myuser")  //得到服务名  只能定义一个同名的服务，否则会报错
public interface OrderApi {
    //查找默认地址的地址信息
    @GetMapping("/auth/address/getDefaultAddress/{isDefault}/{userId}")
    public ResponseEntity<ResponseResult> getDefaultAddress(@PathVariable("isDefault") Integer is_default,
                                                            @PathVariable("userId") Long userId);

    //添加订单（AI客服下单）
    @PostMapping("/auth/orders/addByAI")
    public ResponseEntity<ResponseResult> addOrderByAI(@RequestParam("userId") Long userId,
                                                       @RequestParam("addressId") Long addressId);
    @GetMapping("/auth/orders/findUnfinishedOrder/{orderStatus}")
    public ResponseEntity<ResponseResult> findUnfinishedOrder(@PathVariable("orderStatus") Integer orderStatus,
                                                              @RequestParam(value = "userId", required = false) Long userId);

    //根据订单id修改订单状态
    @PutMapping("/auth/orders/updateOrderStatus/{orderId}/{orderStatus}")
    public ResponseEntity<ResponseResult> updateOrderStatus(@PathVariable("orderId") Long orderId,
                                                            @PathVariable("orderStatus") Integer orderStatus,
                                                            @RequestParam("email") String email);
    //根据id查询订单信息，多表查询
    @GetMapping("/auth/orders/findOrderById/{orderId}")
    public ResponseEntity<ResponseResult> findOrderById(@PathVariable("orderId") Long orderId);


    //添加订单详情
    @PostMapping("/auth/orderdetail/add/{orderId}/details")
    public ResponseEntity<ResponseResult> addDetails(
            @PathVariable("orderId") Long orderId,
            @RequestBody List<OrderdetailDTO> detailList);

    @PostMapping("/auth/alipay/create")
    public ResponseEntity<ResponseResult> createOrder(@RequestParam("orderId") Long orderId,
                                                      @RequestParam("totalAmount") String totalAmount,
                                                      @RequestParam("email") String email);


    //根据订单id查询订单状态
    @GetMapping("/auth/orders/findOrderStatusById/{orderId}")
    public ResponseEntity<ResponseResult> findOrderStatusById(@PathVariable("orderId") Long orderId);
}
